package com.liu.controller;

import com.liu.entity.Admin;
import com.liu.entity.User;
import com.liu.service.intf.AdminService;
import com.liu.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/admin/")
public class AdminController {
    @Autowired
    private AdminService service;
    //新增
    @PostMapping("save.do")
    public R save(Admin admin){
        return service.save(admin);
    }
    //修改
    @PostMapping("update.do")
    public R update(Admin admin){
        return service.update(admin);
    }
    //删除
    @PostMapping("del.do")
    public R del(int id){
        return service.del(id);
    }
    //查询
    @GetMapping("page.do")
    public com.liu.vo.PageBean page(int page, int limit){
        return service.queryPage(page, limit);
    }
    //查询 条件
    @GetMapping("pagewhere.do")
    public com.liu.vo.PageBean page(String username, int page, int limit){
        return service.queryPageWhere(username,page, limit);
    }
    //批量删除 JSON格式的数据请求
    @PostMapping("delbatch.do")
    public R del(@RequestBody int[] ids){
        return service.delBatch(ids);
    }
    @PostMapping("login.do")
    public R login(Admin admin){
        return service.login(admin);
    }
}

